package com.lkd.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lkd.entity.SkuClass;
import com.lkd.mapper.SkuClassMapper;
import com.lkd.service.SkuClassService;
import com.lkd.vo.PageBean;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 商品类别表 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-08-17
 */
@Service
public class SkuClassServiceImpl extends ServiceImpl<SkuClassMapper, SkuClass> implements SkuClassService {



    @Override
    public PageBean<SkuClass> search(String className, Integer pageIndex, Integer pageSize) {
        //分页对象
        Page<SkuClass> page=new Page<>(pageIndex,pageSize);
        LambdaQueryWrapper<SkuClass> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(StrUtil.isNotEmpty(className),SkuClass::getClassName,className);
        page = getBaseMapper().selectPage(page,wrapper);

        return new PageBean<>(page);
    }

    //统计商品类别下有无商品
    @Override
    public Integer getSkuClassCount(Integer classId) {

        return getBaseMapper().getSkuClassCount(classId);
    }
}
